package com.woniuxy.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.woniuxy.entity.BeforeQueryData;
import com.woniuxy.entity.LoanExamLogData;
import com.woniuxy.entity.UserYewuDate;
import com.woniuxy.service.BeforeLoanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/beforeloan")
public class BeforeLoanController extends BaseController {
    @Autowired
    private BeforeLoanService beforeLoanService;

    @GetMapping("/listapply")
    public TableDataInfo listapply(){
        startPage();
        List<UserYewuDate> list = beforeLoanService.listapply();
        return getDataTable(list) ;
    }

    @PostMapping("/queryapply")
    public TableDataInfo queryapply(@RequestBody BeforeQueryData data){
        startPage();
        if(data.getDates()!=null){
            if(data.getDates().length==0){
                data.setDates(null);
            }
        }
        List<UserYewuDate> list = beforeLoanService.queryapply(data);
        return getDataTable(list) ;
    }

    @GetMapping("/listbefore")
    public TableDataInfo listbefore(){
        startPage();
        List<UserYewuDate> list = beforeLoanService.listbefore();
        return getDataTable(list) ;
    }

    @GetMapping("/listexamlog/{id}")
    public TableDataInfo listexamlog(@PathVariable("id") int id){
        startPage();
        List<LoanExamLogData> list = beforeLoanService.listexamlog(id);
        return getDataTable(list) ;
    }

    @PostMapping("/querybefore")
    public TableDataInfo querybefore(@RequestBody BeforeQueryData datas){
        if(datas.getDates()!=null){
            if(datas.getDates().length==0){
                datas.setDates(null);
            }
        }
        startPage();
        List<UserYewuDate> list = beforeLoanService.querybefore(datas);
        return getDataTable(list) ;
    }
}
